using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using Infragistics.Win.UltraWinGrid;
//using RetailAnalytic.Core;


namespace RetailAnalytic.Core.Licence
{
    public partial class frmLoadLicence : frmTemplate
    {
        public frmLoadLicence()
        {
            InitializeComponent();
        }
        private void frmLoadLicence_Load(object sender, EventArgs e)
        {
            this.ugSumLic.DataSource = RetailAnalytic.Core.ModuleSupport.GetLicenceConnect;
            this.ugModul.DataSource = RetailAnalytic.Core.ModuleSupport.GetModulLicence;
        }
        private void ugSumLic_InitializeLayout(object sender, InitializeLayoutEventArgs e)
        {
            for (int i = 0; i < e.Layout.Bands[0].Columns.Count; i++)
            {
                switch (i)
                {
                    case 0:{e.Layout.Bands[0].Columns[i].Width = 240;break;}
                    case 1:{e.Layout.Bands[0].Columns[i].Width = 140;break;}
                    case 2:{e.Layout.Bands[0].Columns[i].Width = 100;break;}
                    case 3:{e.Layout.Bands[0].Columns[i].Width = 100;break;}
                    default:{e.Layout.Bands[0].Columns[i].Width = 90;break;}
                }
                e.Layout.Bands[0].Columns[i].CellActivation = Activation.NoEdit;
            }
        }
        private void ugModul_InitializeLayout(object sender, InitializeLayoutEventArgs e)
        {
            for (int i = 0; i < e.Layout.Bands[0].Columns.Count; i++)
            {
                switch (i)
                {
                    case 0:{e.Layout.Bands[0].Columns[i].Width = 240;break;}
                    case 1: { e.Layout.Bands[0].Columns[i].Width = 140; break; }
                    case 2: { e.Layout.Bands[0].Columns[i].Width = 100; break; }
                    case 3: { e.Layout.Bands[0].Columns[i].Width = 100; break; }
                    default: { e.Layout.Bands[0].Columns[i].Width = 90; break; }
                }
                e.Layout.Bands[0].Columns[i].CellActivation = Activation.NoEdit;
            }
        }
        private void btn_exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btn_Load_Click(object sender, EventArgs e)
        {
            OpenFileDialog _fd = new OpenFileDialog();
            _fd.InitialDirectory = Application.StartupPath;
            _fd.Filter = "lic fileLicence|*.lic";
            if (_fd.ShowDialog() == DialogResult.OK)
            {
                RetailAnalytic.Core.ModuleSupport.SetLicence(_fd.FileName);
                this.ugSumLic.DataSource = RetailAnalytic.Core.ModuleSupport.GetLicenceConnect;
                this.ugModul.DataSource = RetailAnalytic.Core.ModuleSupport.GetModulLicence;
            }
        }
    }
}